<template>
  <div class="home-product" >
    <HomePannel :title="item.name" v-for="item in productslist" :key="item.id" class="product-pannel">
        <template #right>
            <div class="sub">
                <router-link to="/" v-for="sub in item.children" :key="sub.id">{{sub.name}}</router-link>
            </div>
            <!-- 查看全部 -->
            <sy-more></sy-more>
        </template>
        <template #main>
            <div class="box">
                <!-- 左边大图 -->
                <router-link to="/" class="cover">
                    <img v-lazy="item.picture" alt="">
                    <strong class="label">
                        <span>{{item.name}}馆</span>
                        <span>{{item.saleInfo}}</span>
                    </strong>
                </router-link>
                <!-- 右边小图 -->
                <ul class="goods-list">
                    <li v-for="good in item.goods" :key="good.id">
                        <HomeGoods :goods="good"></HomeGoods>
                    </li>
                </ul>
            </div>
        </template>
    </HomePannel>
  </div>
</template>

<script>
import HomePannel from './HomePannel.vue'
import HomeGoods from './HomeGoods.vue'
import { getProductAPI } from '@/api/home'
import { ref } from 'vue'
export default {
  components: {
    HomePannel,
    HomeGoods
  },
  setup () {
    const productslist = ref([])

    getProductAPI().then(data => {
    //   console.log(data)
      productslist.value = data.result
    })

    return { productslist }
  }
}
</script>

<style lang="less" scoped>
.home-product{
    .sub{
        margin-top:4px;
        padding-right: 80px;
        a{
            padding: 2px 12px;
            font-size: 16px;
            border-radius: 4px;
            color: #333;
            &:hover{
                background-color: @themeColor;
                color: #fff;
            }
        }
    }
    .box{
        display: flex;
        .cover{
            position: relative;
            width: 240px;
            height: 610px;
            margin-right:10px ;
            img{
                width: 100%;
                height: 100%;
            }
            .label{
                display: flex;
                position: absolute;
                top: 50%;
                left: 0;
                transform: translateY(-50%);
                width: 188px;
                height: 66px;
                color: #fff;
                line-height: 66px;
                font-weight: normal;
                font-size: 18px;
                span{
                    text-align: center;
                    &:first-child{
                        width: 76px;
                        background: rgba(0, 0, 0, .9);
                    }
                    &:last-child{
                        flex: 1;
                        background: rgba(0, 0, 0, .7);
                    }
                }
            }
        }
        .goods-list{
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            width: 1000px;
        }
    }
}

</style>
